import { request } from "umi";

/**
 * 获取 用户列表
 * @param params
 * @returns
 */
export function get_user_list(
  params: Types.User.IUserSearch
): Promise<Types.Http.Response<Types.User.IUserList>> {
  return request(`/api/v1/admin/user/list`, { params });
}

/**
 * 新增 user
 * @param data
 * @returns
 */
export function add_user(data: Types.User.IUserInfo): Promise<Types.Http.Response<null>> {
  return request("/api/v1/admin/user/create", { data, method: "post" });
}

/**
 * 获取 User 详情
 * @param params
 * @returns
 */
export function get_user_detail(id: string): Promise<Types.Http.Response<Types.User.IUserInfo>> {
  return request("/api/v1/admin/user/detail/" + id);
}

/**
 * 编辑 User
 * @param data
 * @returns
 */
export function edit_user(data: Types.User.IUserInfo): Promise<Types.Http.Response<null>> {
  return request("/api/v1/admin/user/edit", { data, method: "post" });
}

/**
 * 删除 User
 * @param data
 * @returns
 */
export function delete_user(id: string): Promise<Types.Http.Response<null>> {
  return request("/api/v1/admin/user/delete/" + id);
}
